Network: Added IPv6Interface.

* Pretty much the same as the IPv4 one.
This commit is contained in:
Axel Dörfler 2015-03-04 17:09:39 +00:00
parent 59f911ab03
commit 563f3c118d
4 changed files with 179 additions and 5 deletions

View File

@ -1,4 +1,4 @@
SubDir HAIKU_TOP src add-ons network_settings ;
SubInclude HAIKU_TOP src add-ons network_settings ipv4 ;
#SubInclude HAIKU_TOP src add-ons network_settings ipv6 ;
SubInclude HAIKU_TOP src add-ons network_settings ipv6 ;

View File

@ -1,12 +1,8 @@
SubDir HAIKU_TOP src add-ons network_settings ipv4 ;
#UseHeaders [ FDirName $(HAIKU_TOP) src preferences network ] ;
#UseHeaders [ FDirName $(HAIKU_TOP) src servers net ] : true ;
UsePublicHeaders [ FDirName add-ons network_settings ] ;
UsePrivateHeaders shared ;
AddResources Interfaces :
InterfacesIcons.rdef
;

View File

@ -0,0 +1,155 @@
/*
* Copyright 2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, <axeld@pinc-software.de>
*/
#include <Catalog.h>
#include <NetworkSettingsAddOn.h>
#include <StringItem.h>
#include "InterfaceAddressView.h"
using namespace BNetworkKit;
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "IPv6InterfaceAddOn"
class IPv6InterfaceAddOn : public BNetworkSettingsAddOn {
public:
IPv6InterfaceAddOn(image_id image,
BNetworkSettings& settings);
virtual ~IPv6InterfaceAddOn();
virtual BNetworkSettingsInterfaceItem*
CreateNextInterfaceItem(uint32& cookie,
const char* interface);
};
class IPv6InterfaceItem : public BNetworkSettingsInterfaceItem {
public:
IPv6InterfaceItem(const char* interface,
BNetworkSettings& settings);
virtual ~IPv6InterfaceItem();
virtual BListItem* ListItem();
virtual BView* View();
virtual status_t Revert();
virtual bool IsRevertable();
virtual void ConfigurationUpdated(const BMessage& message);
private:
BNetworkSettings& fSettings;
BStringItem* fItem;
InterfaceAddressView*
fView;
};
// #pragma mark -
IPv6InterfaceItem::IPv6InterfaceItem(const char* interface,
BNetworkSettings& settings)
:
BNetworkSettingsInterfaceItem(interface),
fSettings(settings),
fItem(new BStringItem(B_TRANSLATE("IPv6"))),
fView(NULL)
{
}
IPv6InterfaceItem::~IPv6InterfaceItem()
{
if (fView->Parent() == NULL)
delete fView;
delete fItem;
}
BListItem*
IPv6InterfaceItem::ListItem()
{
return fItem;
}
BView*
IPv6InterfaceItem::View()
{
if (fView == NULL)
fView = new InterfaceAddressView(AF_INET6, Interface(), fSettings);
return fView;
}
status_t
IPv6InterfaceItem::Revert()
{
return B_OK;
}
bool
IPv6InterfaceItem::IsRevertable()
{
return false;
}
void
IPv6InterfaceItem::ConfigurationUpdated(const BMessage& message)
{
if (fView != NULL)
fView->ConfigurationUpdated(message);
}
// #pragma mark -
IPv6InterfaceAddOn::IPv6InterfaceAddOn(image_id image,
BNetworkSettings& settings)
:
BNetworkSettingsAddOn(image, settings)
{
}
IPv6InterfaceAddOn::~IPv6InterfaceAddOn()
{
}
BNetworkSettingsInterfaceItem*
IPv6InterfaceAddOn::CreateNextInterfaceItem(uint32& cookie,
const char* interface)
{
if (cookie++ == 0)
return new IPv6InterfaceItem(interface, Settings());
return NULL;
}
// #pragma mark -
extern "C"
BNetworkSettingsAddOn*
instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings)
{
return new IPv6InterfaceAddOn(image, settings);
}

View File

@ -0,0 +1,23 @@
SubDir HAIKU_TOP src add-ons network_settings ipv6 ;
UsePublicHeaders [ FDirName add-ons network_settings ] ;
UsePrivateHeaders shared ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons network_settings ipv4 ] ;
AddResources Interfaces :
InterfacesIcons.rdef
;
Addon IPv6Interface :
IPv6InterfaceAddOn.cpp
InterfaceAddressView.cpp
: be bnetapi libshared.a <nogrist>Network [ TargetLibsupc++ ]
[ TargetLibstdc++ ] localestub
;
DoCatalogs IPv6Interface : x-vnd.Haiku-IPv6Interface :
IPv6InterfaceAddOn.cpp
InterfaceAddressView.cpp
;