Fixed protocol handling.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7068 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b8f24e8376
commit
55c8f8c370
@ -13,6 +13,7 @@
|
||||
|
||||
// built-in add-ons
|
||||
#include "GeneralAddon.h"
|
||||
#include "IPCPAddon.h"
|
||||
#include "PPPoEAddon.h"
|
||||
#include "ProtocolsAddon.h"
|
||||
|
||||
@ -602,6 +603,10 @@ DialUpView::LoadAddons()
|
||||
GeneralAddon *generalAddon = new GeneralAddon(&fAddons);
|
||||
fAddons.AddPointer(DUN_TAB_ADDON_TYPE, generalAddon);
|
||||
fAddons.AddPointer(DUN_DELETE_ON_QUIT, generalAddon);
|
||||
// "IPCP" protocol
|
||||
IPCPAddon *ipcpAddon = new IPCPAddon(&fAddons);
|
||||
fAddons.AddPointer(DUN_PROTOCOL_ADDON_TYPE, ipcpAddon);
|
||||
fAddons.AddPointer(DUN_DELETE_ON_QUIT, ipcpAddon);
|
||||
// "PPPoE" device
|
||||
PPPoEAddon *pppoeAddon = new PPPoEAddon(&fAddons);
|
||||
fAddons.AddPointer(DUN_DEVICE_ADDON_TYPE, pppoeAddon);
|
||||
|
@ -6,6 +6,7 @@ UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkerne
|
||||
|
||||
# additonal headers for built-in add-ons:
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp pppoe ] ; # PPPoE
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp ipcp ] ; # IPCP
|
||||
|
||||
SimpleTest DialUpPreflet :
|
||||
DialUpApplication.cpp
|
||||
@ -17,6 +18,7 @@ SimpleTest DialUpPreflet :
|
||||
|
||||
# built-in add-ons
|
||||
GeneralAddon.cpp
|
||||
IPCPAddon.cpp
|
||||
PPPoEAddon.cpp
|
||||
ProtocolsAddon.cpp
|
||||
;
|
||||
|
@ -143,7 +143,7 @@ PPPoEAddon::IsModified(bool& settings, bool& profile) const
|
||||
return;
|
||||
}
|
||||
|
||||
settings = profile = false;
|
||||
profile = false;
|
||||
settings = (fInterfaceName != fPPPoEView->InterfaceName()
|
||||
|| fACName != fPPPoEView->ACName()
|
||||
|| fServiceName != fPPPoEView->ServiceName());
|
||||
|
@ -82,15 +82,9 @@ ProtocolsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
bool
|
||||
ProtocolsAddon::LoadProtocolSettings(const BMessage& parameter)
|
||||
{
|
||||
// TODO: Maybe we should only load the first add-on because we cannot know
|
||||
// whether the settings are acceptable for all listed protocols.
|
||||
// In addition to this, maybe the protocol itself chose this format because
|
||||
// it consists of two modules.
|
||||
|
||||
// get protocols and ask them to load their settings
|
||||
// get protocol and ask it to load its settings
|
||||
BString name;
|
||||
for(int32 index = 0; parameter.FindString(MDSU_VALUES, index, &name) == B_OK;
|
||||
index++) {
|
||||
if(parameter.FindString(MDSU_VALUES, &name) == B_OK) {
|
||||
DialUpAddon *protocol;
|
||||
if(!GetProtocol(name, &protocol))
|
||||
return false;
|
||||
@ -326,20 +320,20 @@ ProtocolsView::MessageReceived(BMessage *message)
|
||||
switch(message->what) {
|
||||
case MSG_ADD_PROTOCOL: {
|
||||
BMenuItem *selected = fProtocolsMenu->Go(fAddButton->ConvertToScreen(
|
||||
fAddButton->Bounds().RightTop()));
|
||||
|
||||
RegisterProtocol(fProtocolsMenu->IndexOf(selected));
|
||||
fAddButton->Bounds().RightTop()), false, true);
|
||||
|
||||
int32 index = RegisterProtocol(fProtocolsMenu->IndexOf(selected));
|
||||
UpdateButtons();
|
||||
|
||||
if(index > 0)
|
||||
fListView->Select(index);
|
||||
} break;
|
||||
|
||||
case MSG_REMOVE_PROTOCOL: {
|
||||
AddonItem *selected = dynamic_cast<AddonItem*>(
|
||||
fListView->RemoveItem(fListView->CurrentSelection()));
|
||||
|
||||
UnregisterProtocol(fListView->IndexOf(selected));
|
||||
|
||||
UnregisterProtocol(fListView->CurrentSelection());
|
||||
UpdateButtons();
|
||||
|
||||
fListView->Select(0);
|
||||
} break;
|
||||
|
||||
case MSG_SHOW_PREFERENCES: {
|
||||
@ -388,33 +382,33 @@ ProtocolsView::HasProtocol(const BString& moduleName) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
int32
|
||||
ProtocolsView::RegisterProtocol(const DialUpAddon *protocol)
|
||||
{
|
||||
if(!protocol)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
DialUpAddon *addon;
|
||||
BMenuItem *item;
|
||||
for(int32 index = 0; index < fProtocolsMenu->CountItems(); index++) {
|
||||
item = fProtocolsMenu->ItemAt(index);
|
||||
if(item && item->Message()->FindPointer("Addon",
|
||||
reinterpret_cast<void**>(addon)) == B_OK && addon == protocol) {
|
||||
RegisterProtocol(index);
|
||||
return;
|
||||
}
|
||||
reinterpret_cast<void**>(&addon)) == B_OK && addon == protocol)
|
||||
return RegisterProtocol(index);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
int32
|
||||
ProtocolsView::RegisterProtocol(int32 index)
|
||||
{
|
||||
DialUpAddon *addon;
|
||||
BMenuItem *remove = fProtocolsMenu->ItemAt(index);
|
||||
if(!remove || remove->Message()->FindPointer("Addon",
|
||||
reinterpret_cast<void**>(addon)) != B_OK)
|
||||
return;
|
||||
reinterpret_cast<void**>(&addon)) != B_OK)
|
||||
return -1;
|
||||
|
||||
const char *label = remove->Label();
|
||||
AddonItem *item = new AddonItem(label, addon);
|
||||
@ -423,13 +417,16 @@ ProtocolsView::RegisterProtocol(int32 index)
|
||||
fListView->AddItem(item, index);
|
||||
fProtocolsMenu->RemoveItem(remove);
|
||||
delete remove;
|
||||
|
||||
addon->LoadSettings(Addon()->Settings(), Addon()->Profile(), true);
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProtocolsView::UnregisterProtocol(int32 index)
|
||||
{
|
||||
AddonItem *remove = dynamic_cast<AddonItem*>(fListView->ItemAt(index));
|
||||
AddonItem *remove = dynamic_cast<AddonItem*>(fListView->RemoveItem(index));
|
||||
if(!remove)
|
||||
return;
|
||||
|
||||
@ -448,18 +445,19 @@ ProtocolsView::UnregisterProtocol(int32 index)
|
||||
void
|
||||
ProtocolsView::UpdateButtons()
|
||||
{
|
||||
AddonItem *item = dynamic_cast<AddonItem*>(fListView->ItemAt(
|
||||
fListView->CurrentSelection()));
|
||||
|
||||
if(fProtocolsMenu->CountItems() == 0)
|
||||
fAddButton->SetEnabled(false);
|
||||
else
|
||||
fAddButton->SetEnabled(true);
|
||||
|
||||
if(CountProtocols() == 0)
|
||||
if(!item)
|
||||
fRemoveButton->SetEnabled(false);
|
||||
else
|
||||
fRemoveButton->SetEnabled(true);
|
||||
|
||||
AddonItem *item = dynamic_cast<AddonItem*>(fListView->ItemAt(
|
||||
fListView->CurrentSelection()));
|
||||
float width, height;
|
||||
if(!item || !item->Addon()->GetPreferredSize(&width, &height))
|
||||
fPreferencesButton->SetEnabled(false);
|
||||
|
@ -80,8 +80,8 @@ class ProtocolsView : public BView {
|
||||
bool HasProtocol(const BString& moduleName) const;
|
||||
|
||||
private:
|
||||
void RegisterProtocol(const DialUpAddon *protocol);
|
||||
void RegisterProtocol(int32 index);
|
||||
int32 RegisterProtocol(const DialUpAddon *protocol);
|
||||
int32 RegisterProtocol(int32 index);
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user