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